﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using nwrole.toolbox.sync.ServiceHost;
using nwrole.toolbox.sync;

namespace sync_source_console
{
    public static class SyncSettings
    {
        // Chanan
        /*//public static string DestConnectionString = @"Data Source=sl2jlqido0.database.windows.net,1433;Initial Catalog=Alpnaering;Integrated Security=False;Persist Security Info=True;User ID=evolution@sl2jlqido0;Password=sVef#hu8;MultipleActiveResultSets=True";
        public static string DestConnectionString = @"data source=.\SQLEXPRESS;Initial Catalog=SyncTestDest;persist security info=True;Integrated Security=SSPI";
        //public static string SrcConnectionString__ = @"Data Source=runner2.systeamportal.se;Initial Catalog=rick_nop22;User ID=evolution;Password=sVef#hu8;MultipleActiveResultSets=True";

        //public static string SrcConnectionString = @"Data Source=ntalp7;Initial Catalog=ALP1;User ID=sa;Password=as;MultipleActiveResultSets=True";

        //public static string SrcConnectionString = @"Data Source=172.31.6.46;Initial Catalog=PMTestBO;User ID=PMTestBO_user;Password=PMTestBO_user123!;MultipleActiveResultSets=True";
        public static string SrcConnectionString = @"data source=.\SQLEXPRESS;Initial Catalog=SyncTestSource;persist security info=True;Integrated Security=SSPI";*/


        public static string DestDbConnectionString
        {
            get { return ConfigurationManager.ConnectionStrings["SyncDestinationDb"].ConnectionString; }
        }

        public static string SrcDbConnectionString
        {
            get { return ConfigurationManager.ConnectionStrings["SyncSourceDB"].ConnectionString; }
        }
        

        //public static string DestConnectionString = "Data Source=vm-sql01; Initial Catalog=BackOffice_prod; User Id=Backoffice-adm-prod; Password=bo235%adm-prod";
        //public static string SrcConnectionString = "data source=PLOPP;persist security info=True;user id=JFH_BO;password=JFH_BO";

        public static ServiceConnectionInfo.ServiceConnectionType ServiceConnectionType
        {
            get
            {
                ServiceConnectionInfo.ServiceConnectionType type;
                ServiceConnectionInfo.ServiceConnectionType.TryParse(ConfigurationManager.AppSettings["SyncDestinationServiceConnType"], true, out type);
                return type;
            }
        }

        /*public static string ServiceBusIssuerName { get { return ConfigurationManager.AppSettings["SyncServiceSBIssuerName"]; } }
        public static string ServiceBusIssuerSecret { get { return ConfigurationManager.AppSettings["SyncServiceSBIssuerSecret"]; } }
        public static string ServiceBusServiceNamespace { get { return ConfigurationManager.AppSettings["SyncServiceSBServiceNamespace"]; } }
        public static string ServiceBusServicePath { get { return ConfigurationManager.AppSettings["SyncServiceSBServicePath"]; } }

        public static string LocalServiceBaseAddress { get { return ConfigurationManager.AppSettings["SyncSourceLocalBaseAddress"]; } }
        public static string LocalServiceAddress { get { return ConfigurationManager.AppSettings["SyncSourceLocalAddress"]; } }

        public static string SyncDestinationAddress { get { return ConfigurationManager.AppSettings["SyncDestinationAddress"]; } }*/

        public static ServiceConnectionInfo SyncSourceConnInfo
        {
            get
            {
                ServiceConnectionInfo connInfo = new ServiceConnectionInfo();

                ServiceConnectionInfo.ServiceConnectionType type;
                ServiceConnectionInfo.ServiceConnectionType.TryParse(ConfigurationManager.AppSettings["SyncSrcServiceConnType"], true, out type);
                connInfo.Type = type;

                connInfo.ServiceBusServiceNamespace = ConfigurationManager.AppSettings["SyncSrcServiceSBServiceNamespace"];
                connInfo.ServiceBusServicePath = ConfigurationManager.AppSettings["SyncSrcServiceSBServicePath"];
                connInfo.ServiceBusIssuerName = ConfigurationManager.AppSettings["SyncSrcServiceSBIssuerName"];
                connInfo.ServiceBusIssuerSecret = ConfigurationManager.AppSettings["SyncSrcServiceSBIssuerSecret"];

                connInfo.WebServiceBaseAddress = ConfigurationManager.AppSettings["SyncSrcServiceWSBaseAddress"];
                connInfo.WebServiceAddress = ConfigurationManager.AppSettings["SyncSrcServiceWSAddress"];

                return connInfo;
            }
        }

        public static ServiceConnectionInfo SyncDestinationConnInfo
        {
            get
            {
                ServiceConnectionInfo connInfo = new ServiceConnectionInfo();

                ServiceConnectionInfo.ServiceConnectionType type;
                ServiceConnectionInfo.ServiceConnectionType.TryParse(ConfigurationManager.AppSettings["SyncDestServiceConnType"], true, out type);
                connInfo.Type = type;

                connInfo.ServiceBusServiceNamespace = ConfigurationManager.AppSettings["SyncDestServiceSBServiceNamespace"];
                connInfo.ServiceBusServicePath = ConfigurationManager.AppSettings["SyncDestServiceSBServicePath"];
                connInfo.ServiceBusIssuerName = ConfigurationManager.AppSettings["SyncDestServiceSBIssuerName"];
                connInfo.ServiceBusIssuerSecret = ConfigurationManager.AppSettings["SyncDestServiceSBIssuerSecret"];

                connInfo.WebServiceBaseAddress = ConfigurationManager.AppSettings["SyncDestServiceWSBaseAddress"];
                connInfo.WebServiceAddress = ConfigurationManager.AppSettings["SyncDestServiceWSAddress"];

                return connInfo;
            }
        }
    }
}
